package com.changan.controller;

import com.changan.entity.Department;
import com.changan.response.Result;
import com.changan.service.DepartmentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author NieChangan
 * @since 2022-08-30
 */
//@CrossOrigin
@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @ApiOperation(value = "所有部门")
    @GetMapping("/getDepartNameAndCount")
    public Result getDepartNameAndCount() {
        List<Department> departments = departmentService.getDepartNameAndCount();
        return Result.ok().data("departments",departments);
    }

}
